home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / Networking / TalkTool / DDPListener.a < prev    next >
Encoding:
Text File  |  1990-05-18  |  3.6 KB  |  122 lines  |  [TEXT/MPS ]

  1.  
  2.     ;  © 1989 Apple Computer, by Ricardo Batista
  3.     ;  AppleTalk socket listener for TalkTool
  4.  
  5.     STRING PASCAL
  6.  
  7. ddpResult        EQU    2
  8. ddpType            EQU    8
  9. ddpSocket        EQU    10
  10. ddpAddress        EQU    12
  11. ddpReqCount        EQU    16
  12. ddpActCount        EQU    18
  13. ddpDataPtr        EQU    20
  14. ddpNodeID        EQU    24
  15.  
  16.  
  17. tDDPRec            EQU 0
  18. tDDPBuffer        EQU 4
  19. tDDPLen            EQU 8
  20.  
  21. ;
  22. ; if on entry D0 = RICK, then call is to initialize, a1 must have a DDP record pointer.
  23. ; with VM this code must be locked down as well as the buffer and the record pointer !!!
  24. ;
  25.  
  26. DDPListener    PROC    EXPORT
  27.         cmp.l #'RICK',d0                    ; is this my init call ?
  28.         beq @saveDDP                        ; save the address of my DDP handle
  29.         move.w SR,-(sp)                        ; save status register
  30.         ori.w #$2600,SR                        ; disable interrupts
  31.         move.l a5,-(sp)                        ; save this a5
  32.         lea @data,a5                        ; put my data in a5
  33.         move.w d1,tDDPLen(a5)                ; save the len of this packet
  34.         moveq #0,d3                            ; clear d3
  35.         move.w d1,d3                        ; we want to read the whole packet
  36.         move.l tDDPBuffer(a5),a3            ; set buffer address in a3
  37.         move.l (sp)+,a5                        ; recover a5
  38.         jsr 2(a4)                            ; go to ReadRest
  39.         beq.s @getAddr                        ; if there was no error lets fill in DDP info
  40.         move.w (sp)+,SR                        ; recover status register
  41.         rts                                    ; return otherwise (error)
  42.  
  43.     @getAddr:
  44.         move.l a5,-(sp)                        ; save a5
  45.         lea @data,a5                        ; put my data in a5
  46.         move.w tDDPLen(a5),d1                ; put packet length back in d1
  47.         move.l tDDPRec(a5),a5                ; put the DDP pointer in a5
  48.         clr.l d3                            ; clear d3
  49.         clr.w ddpResult(a5)                            ; set result to zero (noErr)
  50.         move.w d1,ddpActCount(a5)                        ; set actual count read
  51.         move.b 1(a2),d3                                    ; put destination node in d3
  52.         move.w d3,ddpNodeID(a5)                            ; set destination node
  53.         cmpi.b #2,3(a2)                                    ; is this long lap header ?
  54.         beq.s @long
  55.         move.b 6(a2),d3                                    ; put destination socket in d3
  56.         move.w d3,ddpSocket(a5)                            ; set destination socket
  57.         move.b 8(a2),d3                                    ; put ddpType in d3
  58.         move.w d3,ddpType(a5)                            ; set ddpType
  59.         move.w $1A(a2),ddpAddress(a5)                    ; set source network address
  60.         move.b 2(a2),ddpAddress+2(a5)                    ; set source node address
  61.         move.b 7(a2),ddpAddress+3(a5)                    ; set source socket address
  62.         move.l (sp)+,a5                                    ; recover a5
  63.         move.w (sp)+,SR                                    ; recover status register
  64.         rts                                                ; return to protocol handler
  65.  
  66.     @long:
  67.         move.w 10(a2),ddpAddress(a5)                    ; set source network address
  68.         move.b 13(a2),ddpAddress+2(a5)                    ; set source node address
  69.         move.b 15(a2),ddpAddress+3(a5)                    ; set source socket number
  70.         move.b 14(a2),d3                                ; put destination socket in d3
  71.         move.w d3,ddpSocket(a5)                            ; set destination socket
  72.         move.b 16(a2),d3                                ; put ddpType in d3
  73.         move.w d3,ddpType(a5)                            ; set ddpType
  74.         move.l (sp)+,a5                                    ; recover a5
  75.         move.w (sp)+,SR                                    ; recover status register
  76.         rts                                                ; return to protocol handler
  77.  
  78.         dc.b '© 1989 Apple Computer, Inc. By Ricardo Batista'
  79.         ALIGN
  80.  
  81.     @saveDDP:
  82.         lea @data,a0                            ; put this data in a0
  83.         move.l a1,tDDPRec(a0)                    ; save my DDP pointer there
  84.         move.l ddpDataPtr(a1),tDDPBuffer(a0)    ; save address of buffer there too
  85.         rts                                        ; return to caller
  86.     @data:
  87.         dc.l    0    ; DDP record pointer
  88.         dc.l    0    ; DDPBuffer address
  89.         dc.w    0    ; packet lenght
  90.     ENDPROC
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101. ;
  102. ; this is a PASCAL type procedure that initializes our socket listener
  103. ; with a DDP record pointer given to it so it can read packets
  104. ;
  105. ;    PROCEDURE InitDDPListener(VAR ddp : ATDDPRec);
  106. ;
  107.  
  108. InitDDPListener    PROC    EXPORT
  109.     move.l #'RICK',d0    ; set our init flag in d0
  110.     move.l 4(a7),a1        ; put the ddp record pointer we are passed in a1
  111.     jsr DDPListener        ; go initialaze our socket listener
  112.     move.l (sp)+,a0        ; recover return address
  113.     adda.l #4,a7        ; recover stack
  114.     jmp (a0)            ; return to our caller
  115.  
  116.     ENDPROC
  117.  
  118.  
  119.  
  120.  
  121.  
  122.     END